package com.studyadmin;

import com.studyadmin.entity.Chapter;
import com.studyadmin.service.ChapterService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.StringReader;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;

import static com.studyadmin.util.SensitiveWordsUtil.textFiltering;

/**
 * @author lyl
 * Date:2023/4/5
 */
public class test2 {

    public static void main(String[] args) {
        String content="hahhaha 傻逼   jdhjshdjs 傻逼  jhj fuck";
        String con=textFiltering(content); //傻逼

        String con2="傻逼";
        System.out.println("-con-"+con);
        System.out.println("--"+con2.getClass().getName());
        String com= content.replace(con, "*");
        String com2= content.replace(con2, "*");
        System.out.println(com+"----"+com2);

//        Scanner sc = new Scanner(System.in);
//        System.out.print("请输入字符串：");
//        String str = sc.nextLine();
//        //创建HashMap集合
//        HashMap<Character, Integer> hm = new HashMap<>();
//        //遍历字符串
//        for (int i = 0; i < str.length(); i++) {
//            //字符串转为字符型，并计算其出现次数，存储与HashMap集合
//            char key = str.charAt(i);
//            Integer value = hm.get(key);
//            if ( value == null){
//                hm.put(key,1);
//            }else {
//                value++;
//                hm.put(key,value);
//            }
//        }
//        //遍历HashMap集合，将其输出
//        StringBuilder sb = new StringBuilder();
//        Set<Character> keySet = hm.keySet();
//        for (Character key : keySet){
//            Integer value = hm.get(key);
//            sb.append(key).append("(").append(value).append(") ");
//        }
//        String result = sb.toString();
//        System.out.println(result);
    }



}
